<%@ tag language="java" pageEncoding="UTF-8"
	deferredSyntaxAllowedAsLiteral="false" trimDirectiveWhitespaces="true"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>
<%@ attribute name="id" required="true" type="java.lang.String"
	description="唯一标识."%>
<%@ attribute name="relationId" required="true" type="java.lang.String"
	description="relationId"%>
<%@ attribute name="relationType" required="false" type="java.lang.String"
	description="relationId"%>
<%@ attribute name="afterSelected" required="false"
	type="java.lang.String" description=""%>
<%@ attribute name="saveUrl" required="true" type="java.lang.String"
	description="saveUrl"%>
<%@ attribute name="listUrl" required="true" type="java.lang.String"
	description="listUrl"%>

<input type="hidden" id="ciSelectorIds">
<isperp:listSelector id="ciSelector" displayValueCssClass="hidden"
	showClearBtn="false" selectorCssClass="hidden"
	urlExtScript=" '&projectId='+($('#projectId').val()?$('#projectId').val():'${projectId }')"
	url="${listUrl }?relationId=${relationId }"
	afterSelected="ciSelector_afterSelected(rows);" multiselect="true">
	<isperp:column name="id" title="id" hidden="true"></isperp:column>
	<isperp:column name="code" title="编号" width="80">
	</isperp:column>
	<isperp:column name="name" title="名称" width="100">
	</isperp:column>
	<isperp:column name="status" title="状态" width="60">
	</isperp:column>
	<isperp:column name="conf_category_name" title="类别" width="80">
	</isperp:column>
	<isperp:column name="cus_customer_name" title="客户" width="100">
	</isperp:column>
</isperp:listSelector>

<script type="text/javascript">
	function selectCi() {
		$('#ciSelector').click();
		return false;

	}
	function ciSelector_afterSelected(rows) {
		if (rows.length < 1) {
			isperp.alert("没有数据被选择！")
			return;
		}
		var ids=rows[0]["${valueColumn}"];
			
		for(var i=1;i<rows.length;i++){
				var item=rows[i];
				ids=ids+","+item["${valueColumn}"];
			}
		$.ajax({
			url : "${saveUrl}",
			data : {
				relationId : '${relationId}',
				relationType : '${relationType }',
				ciId : ids
			},
			success : function(data) {
				if (data.success) {
					${afterSelected}
				} else {
					isperp.alert(data.data);
				}
			},
			error : function(data) {
				isperp.alert(data)
			}
		});

	}
</script>